<%@ page language="java" contentType="text/html; charset=utf8"
	pageEncoding="utf8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="resources/js/jquery-1.7.2.js"></script>
<title>Users</title>
</head>
<body>
	<%-- Hello, <strong>${username}</strong>! You are logined successfully. --%>
	Here is users table
	<br />
	<table border="1">
		<tbody>
			<tr>
				<th>id</th>
				<th>name</th>
				<th>password</th>
				<th>edit</th>
				<th>delete</th>
			</tr>
			<c:forEach items="${users}" var="user">
				<tr>
					<td>${user.id}</td>
					<td>${user.name}</td>
					<td>${user.passwd}</td>
					<td><a href="#"
						onclick="edit(${user.id},'${user.name}','${user.passwd}');return false">edit</a></td>
					<td><a href="users/delete/${user.id}">delete</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<a href="#"onclick="edit('','','');return false">new</a></td>
	<form id="usersForm" action="users/save" method="post">
		<input type="hidden" name="id" id="user_id" /> 
		<input type="text" name="name" id="user_name" /> 
		<input type="text" name="passwd" id="user_passwd" /> 
		<input type="submit" name="save" value="save"></input>
	</form>

	<script type="text/javascript">
	function edit(a,b,c) {
		$("#user_id")[0].value=a;
		$("#user_name")[0].value=b;
		$("#user_passwd")[0].value=c;
	}
	</script>
</body>
</html>